<template>
  <page-dialog
    :title="dialogInfo.title"
    v-model:visible="shows"
    :width="dialogInfo.width"
    :bt-loading="dialogInfo.btLoading"
    :bt-list="dialogInfo.btList"
  >
    <div class="dialog-table">
      <new-page-filter :filter-list="filterInfo.searchBtn">
        <template v-slot:filter-button>
          <div class="dialog-table-header">
            <div class="header-left">
              <div class="lable">资产名称：{{ info.commonName }}</div>
              <div class="lable">验收数量：{{ info.qty }}</div>
            </div>
          </div>
        </template>
      </new-page-filter>
    </div>

    <dialog-table
      v-model:data="info.details"
      :check-box="false"
      :pager="false"
      :tab-index="true"
      :listen-height="false"
      :field-list="tableInfo.fieldList"
    >
    </dialog-table>
  </page-dialog>
</template>

<script setup name="IndividualDetails">
const { proxy } = getCurrentInstance()
const emits = defineEmits()
const props = defineProps({
  showDialog: {
    type: Boolean,
  },
  info: {
    type: Object,
    default: function () {
      return {}
    },
  },
})

// 过滤相关配置
const filterInfo = ref({
  searchBtn: [{ slot: true, value: 'button' }],
})
// 表格相关
const tableInfo = ref({
  refresh: 1,
  initCurpage: 1,
  data: [{}],
  fieldList: [
    { label: '验收数量', value: 'qty' },
    { label: '说明书', value: 'instructionsValue' },
    { label: '合格证', value: 'certificateValue' },
    { label: '保修卡', value: 'warrantyCardValue' },
    { label: '商检单', value: 'buinessInspectOrderValue' },
    { label: '检验报告书', value: 'inspectionReportValue' },
  ],
})
// 弹窗相关
const dialogInfo = ref({
  title: '验收详情',
  width: '90%',
  btLoading: false,
  btList: [{ label: '关闭', event: handleClose, show: true }],
})

const shows = computed({
  get() {
    return props.showDialog
  },
  set(newValue) {
    emits('update:showDialog', newValue) // 更新父组件visible
  },
})
// 关闭弹窗前的回调
function handleClose() {
  shows.value = false
  emits('reset')
}
</script>

<style scoped lang="scss">
:deep(.filter-item) {
  width: 100%;
}
.text-style {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scan-groups {
  display: flex !important;
  align-items: center;
}
</style>
